package com.woniu.mgr.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.woniu.mgr.common.Result;
import com.woniu.mgr.model.Coach;
import com.woniu.mgr.model.Comment;
import com.woniu.mgr.service.CommentService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.naming.factory.ResourceLinkFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author Silas
 * @since 2023-02-15
 */
@RestController
@RequestMapping("/comment")
@Slf4j
public class CommentController {

    @Resource
    private CommentService commentService;

    @GetMapping("/commentSee")
    @ApiOperation("评论分页查询")
    public Result commentSee(Integer page, Integer size) {
        log.info("执行了分页查询操作 {}{}", page, size);
        IPage<Comment> list = commentService.list(page, size);
        return Result.success(200, "查询成功", list);
    }

    @GetMapping("/query")
    public Result query(Integer articleId) {
        log.info("查询{}文章的评论", articleId);
        List<Comment> comments = commentService.query(articleId);
        return Result.success(200, "查询成功", comments);
    }
}

